package cn.com.backstage.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.com.api.entity.ApiT_Cash;
import cn.com.api.entity.ApiT_city;
import cn.com.api.service.ApiCashService;
import cn.com.api.service.ApiShopsService;
import cn.com.api.service.StartOnLoadService;
import cn.com.util.*;
import cn.com.util.*;

@Controller
@RequestMapping(Utils.SYS_BACKSTAGE + "/")
public class CashController {

	private static Logger logger = Logger.getLogger(CashController.class);

	@Autowired
	private ApiShopsService apiShopsService;
	
	@Autowired
	private ApiCashService apiCashService;
	
	@Autowired
	private StartOnLoadService startOnLoadService;

	/**
	 * 进入查询界面
	 * 
	 * @return
	 */
	@RequestMapping(value = "cash-list")
	public ModelAndView list(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(
				"forward:/backstage/cash_list.jsp");

		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		list = apiShopsService.searCashAll();
		mv.addObject("cash", list);

		return mv;
	}
	
	/**
	 * 审核商户提现
	 */
	@RequestMapping(value = "cash-review")
	public void review(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String id=request.getParameter("id");
		String type=request.getParameter("type");
		apiShopsService.cashReview(id, type);
	}
	

	/**
	 * 快递员申请 列表
	 * @return
	 */
	@RequestMapping("courier-transfer-list")
	public ModelAndView courierTransferList(HttpServletRequest request,ApiT_Cash conditions,PageInfo pageInfo) throws Exception{
		ModelAndView mv = new ModelAndView("forward:/backstage/courier_transfer_list.jsp");
		List<ApiT_Cash> transfers = apiCashService.courierTransferList(conditions, pageInfo);
		
		List<ApiT_city> cities = startOnLoadService.citys();
		mv.addObject("transfers", transfers);
		mv.addObject("pageInfo", pageInfo);
		mv.addObject("citys",cities);

		return mv;
	}
}
